//$Id: User.java 3176 2007-01-09 20:53:45Z myuan $
package br.com.rafaelSys.entidades;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;
import org.jboss.seam.annotations.Name;

@Entity
@Name("Usuario")
@Table(name="Usuario")
@NamedQueries({
	@NamedQuery(name="Usuario.findUnique", query="select u from Usuario u where u.username=:username and u.password=:password")
})
public class Usuario implements Serializable
{
	private static final long serialVersionUID = -8451840846967918331L;

	private Integer id;

	private String username;
	private String password;
	private String name;

	public Usuario(String name, String password, String username)
	{
		this.name = name;
		this.password = password;
		this.username = username;
	}

	public Usuario() {}

	@Id
	@GeneratedValue
	public Integer getId()
	{
		return id;
	}
	public void setId(Integer id)
	{
		this.id = id;
	}

	@NotNull
	@Length(max=100)
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}

	@NotNull
	@Length(min=5, max=15)
	public String getPassword()
	{
		return password;
	}
	public void setPassword(String password)
	{
		this.password = password;
	}

	@Length(min=5, max=15)
	@Pattern(regex="^\\w*$", message="not a valid username")
	public String getUsername()
	{
		return username;
	}
	public void setUsername(String username)
	{
		this.username = username;
	}

	@Override
	public String toString() 
	{
		return "User(" + username + ")";
	}
}
